import request from '@/utils/request'

export const dislikeArticle = (articleId) => {
  return request({
    method: 'post',
    url: '/v1_0/article/dislikes',
    data: {
      target: articleId
    }
  })
}

export const reportArticle = (articleId, type, remark) => {
  return request({
    method: 'post',
    url: '/v1_0/article/reports',
    data: {
      target: articleId,
      type,
      remark
    }
  })
}

// 获取文章详情
export const getArticleDetail = (articleId) => {
  return request({
    method: 'get',
    url: `/v1_0/articles/${articleId}`
  })
}

// 获取关注用户
export const follow = (autId) => {
  return request({
    method: 'post',
    url: '/v1_0/user/followings',
    data: {
      target: autId
    }
  })
}

// 取关
export const unFollow = (autId) => {
  return request({
    method: 'delete',
    url: `/v1_0/user/followings/${autId}`
  })
}

// 对文章点赞
export const articleLike = (artId) => {
  return request({
    url: '/v1_0/article/likings',
    method: 'POST',
    data: {
      target: artId
    }
  })
}

// 取消赞
export const articleDislike = (artId) => {
  return request({
    url: `/v1_0/article/likings/${artId}`,
    method: 'delete'
  })
}

// 获取评论数据
export const getCommentList = (source, offset, limit) => {
  return request({
    method: 'get',
    url: '/v1_0/comments',
    params: {
      type: 'a',
      source,
      offset,
      limit
    }
  })
}

// 文章评论点赞
export const likeComment = (comId) => {
  return request({
    method: 'post',
    url: '/v1_0/comment/likings',
    data: {
      target: comId
    }
  })
}

// 评论取消点赞
export const disLikeComment = (comId) => {
  return request({
    method: 'delete',
    url: `/v1_0/comment/likings/${comId}`
  })
}

// 评论 - 发布
export const sendCommentAPI = (target, content) => {
  return request({
    url: '/v1_0/comments',
    method: 'POST',
    data: {
      target,
      content
    }
  })
}
